@jsenv/snapshot 2.6.11 → 2.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -21,7 +21,7 @@ export const replaceFluctuatingValues = (
|
|
|
21
21
|
stringType,
|
|
22
22
|
rootDirectoryUrl,
|
|
23
23
|
fileUrl,
|
|
24
|
-
|
|
24
|
+
preserveAnsi,
|
|
25
25
|
// for unit test
|
|
26
26
|
replaceFilesystemWellKnownValues = createReplaceFilesystemWellKnownValues({
|
|
27
27
|
rootDirectoryUrl,
|
|
@@ -51,7 +51,7 @@ export const replaceFluctuatingValues = (
|
|
|
51
51
|
if (stringType === "filesystem") {
|
|
52
52
|
return replaceFilesystemWellKnownValues(value);
|
|
53
53
|
}
|
|
54
|
-
if (
|
|
54
|
+
if (!preserveAnsi) {
|
|
55
55
|
value = stripAnsi(value);
|
|
56
56
|
}
|
|
57
57
|
value = replaceFilesystemWellKnownValues(value, {
|
|
@@ -37,6 +37,10 @@ export const spyFilesystemCalls = (
|
|
|
37
37
|
const fileDescriptorPathMap = new Map();
|
|
38
38
|
const fileRestoreMap = new Map();
|
|
39
39
|
const onWriteFileDone = (fileUrl, stateBefore, stateAfter) => {
|
|
40
|
+
if (!stateAfter.found) {
|
|
41
|
+
// not suppoed to happen but could apparently
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
40
44
|
// we use same type because we don't want to differentiate between
|
|
41
45
|
// - writing file for the 1st time
|
|
42
46
|
// - updating file content
|
|
@@ -246,6 +246,7 @@ const renderText = (
|
|
|
246
246
|
typeof value.stack === "string")
|
|
247
247
|
) {
|
|
248
248
|
onRenderError();
|
|
249
|
+
// return renderMarkdownBlock(text.value.stack);
|
|
249
250
|
const exception = createException(text.value, { rootDirectoryUrl });
|
|
250
251
|
const exceptionText = errorStackHidden
|
|
251
252
|
? `${exception.name}: ${exception.message}`
|
|
@@ -306,24 +307,36 @@ const renderPotentialAnsi = (
|
|
|
306
307
|
string,
|
|
307
308
|
{ stringType, sideEffect, sideEffectFileUrl, generateOutFileUrl, replace },
|
|
308
309
|
) => {
|
|
310
|
+
const rawTextBlock = renderMarkdownBlock(
|
|
311
|
+
replace(string, { stringType }),
|
|
312
|
+
"console",
|
|
313
|
+
);
|
|
309
314
|
// for assert we want ideally hummm
|
|
310
315
|
// colored in details block?
|
|
311
316
|
const includesAnsi = ansiRegex().test(string);
|
|
312
317
|
if (!includesAnsi) {
|
|
313
|
-
return
|
|
318
|
+
return rawTextBlock;
|
|
314
319
|
}
|
|
315
320
|
const svgFilename = `${sideEffect.code}${sideEffect.counter ? `_${sideEffect.counter}` : ""}.svg`;
|
|
316
321
|
const svgFileUrl = generateOutFileUrl(svgFilename);
|
|
317
|
-
let svgFileContent = renderTerminalSvg(
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
+
let svgFileContent = renderTerminalSvg(
|
|
323
|
+
replace(string, { stringType: "console", preserveAnsi: true }),
|
|
324
|
+
{
|
|
325
|
+
head: false,
|
|
326
|
+
paddingTop: 10,
|
|
327
|
+
paddingBottom: 10,
|
|
328
|
+
},
|
|
329
|
+
);
|
|
322
330
|
svgFileContent = replace(svgFileContent, { fileUrl: svgFileUrl });
|
|
323
331
|
writeFileSync(svgFileUrl, svgFileContent);
|
|
324
332
|
const svgFileRelativeUrl = urlToRelativeUrl(svgFileUrl, sideEffectFileUrl);
|
|
325
|
-
|
|
326
|
-
|
|
333
|
+
let md = ``;
|
|
334
|
+
md += "\n\n";
|
|
335
|
+
md += renderMarkdownDetails(`${rawTextBlock}`, {
|
|
336
|
+
summary: "see without style",
|
|
337
|
+
});
|
|
338
|
+
md += "\n";
|
|
339
|
+
return md;
|
|
327
340
|
};
|
|
328
341
|
|
|
329
342
|
export const renderFileContent = (text, { sideEffect, replace }) => {
|
|
@@ -22,9 +22,9 @@ export const snapshotTests = async (
|
|
|
22
22
|
{
|
|
23
23
|
testName = urlToBasename(testFileUrl, true),
|
|
24
24
|
sideEffectFileUrl,
|
|
25
|
-
sideEffectFilePattern = "./output/[test_name]
|
|
25
|
+
sideEffectFilePattern = "./output/[test_name].md",
|
|
26
26
|
outDirectoryPattern = "./output/[test_name]/",
|
|
27
|
-
outFilePattern = "./output/[
|
|
27
|
+
outFilePattern = "./output/[test_scenario]/[filename]",
|
|
28
28
|
rootDirectoryUrl,
|
|
29
29
|
generatedBy = true,
|
|
30
30
|
linkToSource = true,
|